package _1_PIO.excel.样式;

import org.apache.poi.ss.usermodel.*;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import org.junit.jupiter.api.Test;

import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStream;

/**
 * 填充和颜色
 */
public class _3_FIllsAndColors {

    @Test
    public void _2003(){}


    @Test
    public void _2007() throws IOException {
        Workbook workbook = new XSSFWorkbook();
        Sheet sheet = workbook.createSheet();
        Row row = sheet.createRow(1);

        CellStyle cellStyle = workbook.createCellStyle();
        cellStyle.setFillForegroundColor(IndexedColors.AQUA.getIndex());
        cellStyle.setFillPattern(FillPatternType.BIG_SPOTS);

        Cell cell = row.createCell(1);
        cell.setCellValue("X");
        cell.setCellStyle(cellStyle);

        cellStyle = workbook.createCellStyle();
//        cellStyle.setFillForegroundColor(IndexedColors.ORANGE.getIndex());
//        cellStyle.setFillPattern(FillPatternType.SOLID_FOREGROUND);

        cell = row.createCell(2);
        cell.setCellValue("X");
        cell.setCellStyle(cellStyle);

        try(OutputStream outputStream = new FileOutputStream("D:\\workbook.xlsx")){
            workbook.write(outputStream);
        }
        finally {
            workbook.close();
        }
    }

}
